package kalambury.srv;

import java.net.Socket;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 06.11.12
 * Time: 16:02
 * To change this template use File | Settings | File Templates.
 */

/**
 * klasa przechowująca stan gry
 */
public class GameState {
    /**
     * lista graczy
     */
    public HashMap<String, UserSocket> players = new HashMap<String, UserSocket>();
    /**
     * aktualnie zgadywane hasło
     */
    public String currentPass = passwords[rand.nextInt(passwords.length)];

    /**
     * losuje nowe hasło
     */
    public void pickNewPassword() {
        int index = rand.nextInt(passwords.length);
        int currIndex = 0;
        for(String s : passwords){
            if(s.equals(currentPass))
                break;
            ++currIndex;
        }
        if (index==currIndex)
            index = (index+1)%passwords.length;
        currentPass = passwords[index];
    }

    private static final Random rand = new Random();

    /**
     * lista możliwych haseł
     */
    private static final String[] passwords = new String[]{
            "krzesło", "wielbłąd", "szkoła", "książka", "komputer", "miecz", "stół", "telewizor", "narty", "makaron"
    };
}
